2 # MediaWiki web-based config/installation
3 # Copyright (C) 2004 Brion Vibber <brion@pobox.com>
4 # http://www.mediawiki.org/
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along
17 # with this program; if not, write to the Free Software Foundation, Inc.,
18 # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 # http://www.gnu.org/copyleft/gpl.html
21 error_reporting( E_ALL
);
22 header( "Content-type: text/html; charset=utf-8" );
23 @ini_set
( "display_errors", true );
25 ?
><!DOCTYPE HTML
PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
26 "http://www.w3.org/TR/html4/loose.dtd">
29 <meta http
-equiv
="Content-type" content
="text/html; charset=utf-8">
30 <meta name
="robots" content
="noindex,nofollow">
31 <title
>MediaWiki installation
</title
>
32 <style type
="text/css">
37 background
-color
: #eee;
39 border
: solid
1px
#444;
47 dl
.setup dd label
.column
{
59 /* margin-right: 200px; */
77 <a href
="http://www.mediawiki.org/">
78 <img src
="../skins/common/images/mediawiki.png" width
="135" height
="135" alt
="" border
="0" />
82 <strong
><a href
="http://www.mediawiki.org/">MediaWiki
</a
></strong
> is
83 Copyright (C
) 2001-<?
=date('Y')?
> by Magnus Manske
, Brion Vibber
, Lee Daniel Crocker
,
84 Tim Starling
, Erik M
ö
;ller
, Gabriel Wicke
, Thomas Gries
and others
.</p
>
87 <li
><a href
="../README">Readme
</a
></li
>
88 <li
><a href
="../RELEASE-NOTES">Release notes
</a
></li
>
89 <li
><a href
="../docs/">doc
/</a
></li
>
90 <li
><a href
="http://meta.wikipedia.org/wiki/MediaWiki_User's_Guide">User
's Guide</a></li>
93 <p>This program is free software; you can redistribute it and/or modify
94 it under the terms of the GNU General Public License as published by
95 the Free Software Foundation; either version 2 of the License, or
96 (at your option) any later version.</p>
98 <p>This program is distributed in the hope that it will be useful,
99 but WITHOUT ANY WARRANTY; without even the implied warranty of
100 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
101 GNU General Public License for more details.</p>
103 <p>You should have received <a href="../COPYING">a copy of the GNU General Public License</a>
104 along with this program; if not, write to the Free Software
105 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
106 or <a href="http://www.gnu.org/copyleft/gpl.html">read it online</a></p>
111 # Relative includes seem to break if a parent directory is not readable;
112 # this is common for public_html subdirs under user home directories.
114 # As a dirty hack, we'll
try to set up the
include path first
.
116 $IP = dirname( dirname( __FILE__
) );
117 $sep = (DIRECTORY_SEPARATOR
== "\\") ?
";" : ":";
118 ini_set( "include_path", ".$sep$IP$sep$IP/includes$sep$IP/languages" );
120 define( "MEDIAWIKI", true );
121 define( "MEDIAWIKI_INSTALL", true );
122 require_once( "includes/Defines.php" );
123 require_once( "includes/DefaultSettings.php" );
124 require_once( "includes/MagicWord.php" );
125 require_once( "includes/Namespace.php" );
128 <h1
>MediaWiki
<?php
print $wgVersion ?
> installation
</h1
>
133 /* Check for existing configurations and bug out! */
135 if( file_exists( "../LocalSettings.php" ) ) {
136 dieout( "<h2>Wiki is configured.</h2>
138 <p>Already configured... <a href='../index.php'>return to the wiki</a>.</p>
140 <p>(You should probably remove this directory for added security.)</p>" );
143 if( file_exists( "./LocalSettings.php" ) ) {
144 dieout( "<h2>You're configured!</h2>
146 <p>Please move <tt>LocalSettings.php</tt> to the parent directory, then
147 <a href='../index.php'>try out your wiki</a>.
148 (You should remove this config directory for added security once you're done.)</p>" );
151 if( !is_writable( "." ) ) {
152 dieout( "<h2>Can't write config file, aborting</h2>
154 <p>In order to configure the wiki you have to make the <tt>config</tt> subdirectory
155 writable by the web server. Once configuration is done you'll move the created
156 <tt>LocalSettings.php</tt> to the parent directory, and for added safety you can
157 then remove the <tt>config</tt> subdirectory entirely.</p>
159 <p>To make the directory writable on a Unix/Linux system:</p>
162 <tt>cd /path/to/wiki</tt><br>
163 <tt>chmod a+w config</tt>
168 require_once( "install-utils.inc" );
169 require_once( "maintenance/updaters.inc" );
170 require_once( "maintenance/convertLinks.inc" );
171 require_once( "maintenance/archives/moveCustomMessages.inc" );
174 function getEncoded( $data ) {
175 # removing latin1 support, no need...
178 function getSitename() { return $this->getEncoded( $this->Sitename
); }
179 function getSysopName() { return $this->getEncoded( $this->SysopName
); }
180 function getSysopPass() { return $this->getEncoded( $this->SysopPass
); }
185 <p
><em
>Please
include all of the lines below when reporting installation problems
.</em
></p
>
187 <h2
>Checking environment
...</h2
>
192 $wgNoOutputBuffer = true;
193 $conf = new ConfigData
;
195 install_version_checks();
197 print "<li>PHP " . phpversion() . ": ok</li>\n";
199 if( ini_get( "register_globals" ) ) {
201 <li
><b
class='error'>Warning
:</b
> <strong
>PHP
's
202 <tt><a href="http://php.net/register_globals">register_globals</a></tt>
203 option is enabled.</strong> MediaWiki will work correctly, but this setting
204 increases your exposure to potential security vulnerabilities in PHP-based
205 software running on your server. <strong>You should disable it if you are able.</strong></li>
209 if( ini_get( "safe_mode" ) ) {
211 <li class='error
'><strong>Warning: PHP's
212 <a href
='http://www.php.net/features.safe-mode'>safe mode
</a
> is active
!</strong
>
213 You may have problems caused by this
, particularly
if using image uploads
.
220 if( ini_get( "magic_quotes_runtime" ) ) {
222 ?
><li
class='error'><strong
>Fatal
: <a href
='http://www.php.net/manual/en/ref.info.php#ini.magic-quotes-runtime'>magic_quotes_runtime
</a
> is active
!</strong
>
223 This option corrupts data input unpredictably
; you cannot install
or use
224 MediaWiki unless this option is disabled
.
228 if( ini_get( "magic_quotes_sybase" ) ) {
230 ?
><li
class='error'><strong
>Fatal
: <a href
='http://www.php.net/manual/en/ref.sybase.php#ini.magic-quotes-sybase'>magic_quotes_sybase
</a
> is active
!</strong
>
231 This option corrupts data input unpredictably
; you cannot install
or use
232 MediaWiki unless this option is disabled
.
237 dieout( "</ul><p>Cannot install wiki.</p>" );
240 $sapi = php_sapi_name();
241 $conf->prettyURLs
= true;
242 print "<li>PHP server API is $sapi; ";
245 case "apache2handler":
246 print "ok, using pretty URLs (<tt>index.php/Page_Title</tt>)";
250 case "apache2filter":
251 print "using ugly URLs (<tt>index.php?title=Page_Title</tt>)";
252 $conf->prettyURLs
= false;
255 print "unknown; using pretty URLs (<tt>index.php/Page_Title</tt>), if you have trouble change this in <tt>LocalSettings.php</tt>";
259 $conf->xml
= function_exists( "utf8_encode" );
261 print "<li>Have XML / Latin1-UTF-8 conversion support.</li>\n";
263 dieout( "PHP's XML module is missing; the wiki requires functions in
264 this module and won't work in this configuration.
265 If you're running Mandrake, install the php-xml package." );
268 $memlimit = ini_get( "memory_limit" );
269 $conf->raiseMemory
= false;
270 if( empty( $memlimit ) ) {
271 print "<li>PHP is configured with no <tt>memory_limit</tt>.</li>\n";
273 print "<li>PHP's <tt>memory_limit</tt> is " . htmlspecialchars( $memlimit ) . ". <strong>If this is too low, installation may fail!</strong> ";
274 $n = IntVal( $memlimit );
275 if( preg_match( '/^([0-9]+)[Mm]$/', trim( $memlimit ), $m ) ) {
276 $n = IntVal( $m[1] * (1024*1024) );
278 if( $n < 20*1024*1024 ) {
279 print "Attempting to raise limit to 20M... ";
280 if( false === ini_set( "memory_limit", "20M" ) ) {
283 $conf->raiseMemory
= true;
290 $conf->zlib
= function_exists( "gzencode" );
292 print "<li>Have zlib support; enabling output compression.</li>\n";
294 print "<li>No zlib support.</li>\n";
297 $conf->turck
= function_exists( 'mmcache_get' );
298 if ( $conf->turck
) {
299 print "<li><a href=\"http://turck-mmcache.sourceforge.net/\">Turck MMCache</a> installed</li>\n";
301 $conf->eaccel
= function_exists( 'eaccelerator_get' );
302 if ( $conf->eaccel
) {
303 $conf->turck
= 'eaccelerator';
304 print "<li><a href=\"http://eaccelerator.sourceforge.net/\">eAccelerator</a> installed</li>\n";
306 if (!$conf->turck
&& !$conf->eaccel
) {
307 print "<li>Neither <a href=\"http://turck-mmcache.sourceforge.net/\">Turck MMCache</a> nor <a href=\"http://eaccelerator.sourceforge.net/\">eAccelerator</a> are installed, " .
308 "can't use object caching functions</li>\n";
311 $conf->ImageMagick
= false;
312 $imcheck = array( "/usr/bin", "/usr/local/bin", "/sw/bin", "/opt/local/bin" );
313 foreach( $imcheck as $dir ) {
314 $im = "$dir/convert";
315 if( file_exists( $im ) ) {
316 print "<li>Found ImageMagick: <tt>$im</tt>; image thumbnailing will be enabled if you enable uploads.</li>\n";
317 $conf->ImageMagick
= $im;
322 $conf->HaveGD
= function_exists( "imagejpeg" );
323 if( $conf->HaveGD
) {
324 print "<li>Found GD graphics library built-in";
325 if( !$conf->ImageMagick
) {
326 print ", image thumbnailing will be enabled if you enable uploads";
330 if( !$conf->ImageMagick
) {
331 print "<li>Couldn't find GD library or ImageMagick; image thumbnailing disabled.</li>\n";
335 $conf->UseImageResize
= $conf->HaveGD ||
$conf->ImageMagick
;
337 # $conf->IP = "/Users/brion/Sites/inplace";
338 $conf->IP
= dirname( dirname( __FILE__
) );
339 print "<li>Installation directory: <tt>" . htmlspecialchars( $conf->IP
) . "</tt></li>\n";
341 # $conf->ScriptPath = "/~brion/inplace";
342 $conf->ScriptPath
= preg_replace( '{^(.*)/config.*$}', '$1', $_SERVER["PHP_SELF"] ); # was SCRIPT_NAME
343 print "<li>Script URI path: <tt>" . htmlspecialchars( $conf->ScriptPath
) . "</tt></li>\n";
345 $conf->posted
= ($_SERVER["REQUEST_METHOD"] == "POST");
347 $conf->Sitename
= ucfirst( importPost( "Sitename", "" ) );
348 $defaultEmail = empty( $_SERVER["SERVER_ADMIN"] )
350 : $_SERVER["SERVER_ADMIN"];
351 $conf->EmergencyContact
= importPost( "EmergencyContact", $defaultEmail );
352 $conf->DBserver
= importPost( "DBserver", "localhost" );
353 $conf->DBname
= importPost( "DBname", "wikidb" );
354 $conf->DBuser
= importPost( "DBuser", "wikiuser" );
355 $conf->DBpassword
= importPost( "DBpassword" );
356 $conf->DBpassword2
= importPost( "DBpassword2" );
357 $conf->DBprefix
= importPost( "DBprefix" );
358 $conf->RootPW
= importPost( "RootPW" );
359 $conf->LanguageCode
= importPost( "LanguageCode", "en" );
360 $conf->SysopName
= importPost( "SysopName", "WikiSysop" );
361 $conf->SysopPass
= importPost( "SysopPass" );
362 $conf->SysopPass2
= importPost( "SysopPass2" );
364 /* Check for validity */
367 if( $conf->Sitename
== "" ||
$conf->Sitename
== "MediaWiki" ||
$conf->Sitename
== "Mediawiki" ) {
368 $errs["Sitename"] = "Must not be blank or \"MediaWiki\".";
370 if( $conf->DBuser
== "" ) {
371 $errs["DBuser"] = "Must not be blank";
373 if( $conf->DBpassword
== "" ) {
374 $errs["DBpassword"] = "Must not be blank";
376 if( $conf->DBpassword
!= $conf->DBpassword2
) {
377 $errs["DBpassword2"] = "Passwords don't match!";
379 if( !preg_match( '/^[A-Za-z_0-9]*$/', $conf->DBprefix
) ) {
380 $errs["DBprefix"] = "Invalid table prefix";
383 if( $conf->SysopPass
== "" ) {
384 $errs["SysopPass"] = "Must not be blank";
386 if( $conf->SysopPass
!= $conf->SysopPass2
) {
387 $errs["SysopPass2"] = "Passwords don't match!";
390 $conf->License
= importRequest( "License", "none" );
391 if( $conf->License
== "gfdl" ) {
392 $conf->RightsUrl
= "http://www.gnu.org/copyleft/fdl.html";
393 $conf->RightsText
= "GNU Free Documentation License 1.2";
394 $conf->RightsCode
= "gfdl";
395 $conf->RightsIcon
= '${wgStylePath}/common/images/gnu-fdl.png';
396 } elseif( $conf->License
== "none" ) {
397 $conf->RightsUrl
= $conf->RightsText
= $conf->RightsCode
= $conf->RightsIcon
= "";
399 $conf->RightsUrl
= importRequest( "RightsUrl", "" );
400 $conf->RightsText
= importRequest( "RightsText", "" );
401 $conf->RightsCode
= importRequest( "RightsCode", "" );
402 $conf->RightsIcon
= importRequest( "RightsIcon", "" );
405 $conf->Shm
= importRequest( "Shm", "none" );
406 $conf->MCServers
= importRequest( "MCServers" );
408 /* Test memcached servers */
410 if ( $conf->Shm
== 'memcached' && $conf->MCServers
) {
411 $conf->MCServerArray
= array_map( 'trim', explode( ',', $conf->MCServers
) );
412 foreach ( $conf->MCServerArray
as $server ) {
413 $error = testMemcachedServer( $server );
415 $errs["MCServers"] = $error;
419 } else if ( $conf->Shm
== 'memcached' ) {
420 $errs["MCServers"] = "Please specify at least one server if you wish to use memcached";
423 /* default values for installation */
424 $conf->Email
=importRequest("Email", "email_enabled");
425 $conf->Emailuser
=importRequest("Emailuser", "emailuser_enabled");
426 $conf->Enotif
=importRequest("Enotif", "enotif_allpages");
427 $conf->Eauthent
=importRequest("Eauthent", "eauthent_enabled");
429 if( $conf->posted
&& ( 0 == count( $errs ) ) ) {
430 do { /* So we can 'continue' to end prematurely */
431 $conf->Root
= ($conf->RootPW
!= "");
433 /* Load up the settings and get installin' */
434 $local = writeLocalSettings( $conf );
435 $wgCommandLineMode = false;
438 $wgDBadminuser = "root";
439 $wgDBadminpassword = $conf->RootPW
;
440 $wgDBprefix = $conf->DBprefix
;
441 $wgCommandLineMode = true;
442 $wgUseDatabaseMessages = false; /* FIXME: For database failure */
443 require_once( "includes/Setup.php" );
446 require_once( "maintenance/InitialiseMessages.inc" );
448 $wgTitle = Title
::newFromText( "Installation script" );
449 $wgDatabase = Database
::newFromParams( $wgDBserver, "root", $conf->RootPW
, "", 1 );
450 $wgDatabase->ignoreErrors(true);
452 @$myver = mysql_get_server_info( $wgDatabase->mConn
);
455 print "<li>Connected as root (automatic)</li>\n";
457 print "<li>MySQL error " . ($err = mysql_errno() ) .
458 ": " . htmlspecialchars( mysql_error() );
464 $errs["RootPW"] = "Check password";
466 print "<li>Trying regular user...\n";
467 /* Try the regular user... */
468 $wgDBadminuser = $wgDBuser;
469 $wgDBadminpassword = $wgDBpassword;
470 $wgDatabase = Database
::newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, "", 1 );
471 $wgDatabase->isOpen();
472 $wgDatabase->ignoreErrors(true);
473 @$myver = mysql_get_server_info( $wgDatabase->mConn
);
475 $errs["DBuser"] = "Check name/pass";
476 $errs["DBpassword"] = "or enter root";
477 $errs["DBpassword2"] = "password below";
478 $errs["RootPW"] = "Got root?";
479 print " need password.</li>\n";
491 $errs["DBserver"] = "Connection failed";
494 $errs["DBserver"] = "Couldn't connect to database";
500 if ( !$wgDatabase->isOpen() ) {
501 $errs["DBserver"] = "Couldn't connect to database";
505 print "<li>Connected to database... $myver";
506 if( version_compare( $myver, "4.0.0" ) >= 0 ) {
507 print "; enabling MySQL 4 enhancements";
508 $conf->DBmysql4
= true;
509 $local = writeLocalSettings( $conf );
513 @$sel = mysql_select_db( $wgDBname, $wgDatabase->mConn
);
515 print "<li>Database <tt>" . htmlspecialchars( $wgDBname ) . "</tt> exists</li>\n";
517 $res = $wgDatabase->query( "CREATE DATABASE `$wgDBname`" );
519 print "<li>Couldn't create database <tt>" .
520 htmlspecialchars( $wgDBname ) .
521 "</tt>; try with root access or check your username/pass.</li>\n";
522 $errs["RootPW"] = "<- Enter";
525 print "<li>Created database <tt>" . htmlspecialchars( $wgDBname ) . "</tt></li>\n";
528 $wgDatabase->selectDB( $wgDBname );
530 if( $wgDatabase->tableExists( "cur" ) ||
$wgDatabase->tableExists( "revision" ) ) {
531 print "<li>There are already MediaWiki tables in this database. Checking if updates are needed...</li>\n";
533 # Create user if required
535 $conn = Database
::newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1 );
536 if ( $conn->isOpen() ) {
537 print "<li>DB user account ok</li>\n";
540 print "<li>Granting user permissions...</li>\n";
541 dbsource( "../maintenance/users.sql", $wgDatabase );
551 print "<li>Finished update checks.</li>\n";
553 # FIXME: Check for errors
554 print "<li>Creating tables...";
555 dbsource( "../maintenance/tables.sql", $wgDatabase );
556 dbsource( "../maintenance/interwiki.sql", $wgDatabase );
557 dbsource( "../maintenance/archives/patch-userlevels-defaultgroups.sql", $wgDatabase );
558 print " done.</li>\n";
560 print "<li>Initializing data...";
561 $wgDatabase->insert( 'site_stats',
562 array( 'ss_row_id' => 1,
563 'ss_total_views' => 0,
564 'ss_total_edits' => 0,
565 'ss_good_articles' => 0 ) );
566 # setting up the db user
568 print "<li>Granting user permissions...</li>\n";
569 dbsource( "../maintenance/users.sql", $wgDatabase );
572 if( $conf->SysopName
) {
573 $u = User
::newFromName( $conf->getSysopName() );
574 if ( 0 == $u->idForName() ) {
576 $u->setPassword( $conf->getSysopPass() );
577 $u->addRight( "sysop" );
578 $u->addRight( "bureaucrat" );
581 # Set up the new user in the sysop group
582 # This is a bit of an ugly hack
583 global $wgSysopGroupId, $wgBureaucratGroupId;
584 $groups = $u->getGroups();
585 $groups[] = $wgSysopGroupId;
586 $groups[] = $wgBureaucratGroupId;
587 $u->setGroups( $groups );
590 print "<li>Created sysop account <tt>" .
591 htmlspecialchars( $conf->SysopName
) . "</tt>.</li>\n";
593 print "<li>Could not create user - already exists!</li>\n";
596 print "<li>Skipped sysop account creation, no name given.</li>\n";
599 $titleobj = Title
::newFromText( wfMsgNoDB( "mainpage" ) );
600 $article = new Article( $titleobj );
601 $newid = $article->insertOn( $wgDatabase );
602 $revision = new Revision( array(
604 'text' => wfMsg( 'mainpagetext' ) . "\n\n" . wfMsg( 'mainpagedocfooter' ),
607 'user_text' => 'MediaWiki default',
609 $revid = $revision->insertOn( $wgDatabase );
610 $article->updateRevisionOn( $wgDatabase, $revision );
613 initialiseMessages();
614 print "</pre></li>\n";
617 /* Write out the config file now that all is well */
618 print "<p>Creating LocalSettings.php...</p>\n\n";
619 $localSettings = "<" . "?php$endl$local$endl?" . ">";
620 // Fix up a common line-ending problem (due to CVS on Windows)
621 $localSettings = str_replace( "\r\n", "\n", $localSettings );
623 if( version_compare( phpversion(), "4.3.2" ) >= 0 ) {
624 $xt = "xt"; # Refuse to overwrite an existing file
626 $xt = "wt"; # 'x' is not available prior to PHP 4.3.2. We did check above, but race conditions blah blah
628 $f = fopen( "LocalSettings.php", $xt );
631 dieout( "<p>Couldn't write out LocalSettings.php. Check that the directory permissions are correct and that there isn't already a file of that name here...</p>\n" .
632 "<p>Here's the file that would have been written, try to paste it into place manually:</p>\n" .
633 "<pre>\n" . htmlspecialchars( $localSettings ) . "</pre>\n" );
635 if(fwrite( $f, $localSettings ) ) {
638 print "<p>Success! Move the config/LocalSettings.php file into the parent directory, then follow
639 <a href='{$conf->ScriptPath}/index.php'>this link</a> to your wiki.</p>\n";
642 die("<p class='error'>An error occured while writing the config/LocalSettings.php file. Check user rights and disk space then try again.</p>\n");
654 if( count( $errs ) ) {
655 /* Display options form */
657 if( $conf->posted
) {
658 echo "<p class='error'>Something's not quite right yet; make sure everything below is filled out correctly.</p>\n";
662 <form name
="config" method
="post">
670 aField( $conf, "Sitename", "Site name:" );
674 Your site name should be a relatively short word
. It
'll appear as the namespace
675 name for 'meta
' pages as well as throughout the user interface. Good site names
676 are things like "<a href="http://www.wikipedia.org/">Wikipedia</a>" and
677 "<a href="http://openfacts.berlios.de/">OpenFacts</a>"; avoid punctuation,
678 which may cause problems.
683 aField( $conf, "EmergencyContact", "Contact e-mail" );
687 This will be used as the return address for password reminders and
688 may be displayed in some error conditions so visitors can get in
689 touch with you. It is also be used as the default sender address of e-mail
690 notifications (enotifs).
694 <label class='column
' for="LanguageCode">Language</label>
695 <select id="LanguageCode" name="LanguageCode">
698 $list = getLanguageList();
699 foreach( $list as $code => $name ) {
700 $sel = ($code == $conf->LanguageCode) ? 'selected
="selected"' : '';
701 echo "\t\t<option value=\"$code\" $sel>$name</option>\n";
707 You may select the language for the user interface of the wiki...
708 Some localizations are less complete than others. Unicode (UTF-8 encoding)
709 is used for all localizations.
713 <label class='column
'>Copyright/license metadata</label>
714 <div>Select one:</div>
717 <li><?php aField( $conf, "License", "no license metadata", "radio", "none" ); ?></li>
718 <li><?php aField( $conf, "License", "GNU Free Documentation License 1.2 (Wikipedia-compatible)", "radio", "gfdl" ); ?></li>
720 aField( $conf, "License", "a Creative Commons license...", "radio", "cc" );
721 $partner = "MediaWiki";
722 $exit = urlencode( "$wgServer{$conf->ScriptPath}/config/index.php?License=cc&RightsUrl=[license_url]&RightsText=[license_name]&RightsCode=[license_code]&RightsIcon=[license_button]" );
723 $icon = urlencode( "$wgServer$wgUploadPath/wiki.png" );
724 $ccApp = htmlspecialchars( "http://creativecommons.org/license/?partner=$partner&exit_url=$exit&partner_icon_url=$icon" );
725 print "<a href=\"$ccApp\">choose</a>";
726 ?> (link will wipe out any other data in this form!)
727 <?php if( $conf->License == "cc" ) { ?>
729 <li><?php aField( $conf, "RightsIcon", "<img src=\"" . htmlspecialchars( $conf->RightsIcon ) . "\" alt='icon
' />", "hidden" ); ?></li>
730 <li><?php aField( $conf, "RightsText", htmlspecialchars( $conf->RightsText ), "hidden" ); ?></li>
731 <li><?php aField( $conf, "RightsCode", "code: " . htmlspecialchars( $conf->RightsCode ), "hidden" ); ?></li>
732 <li><?php aField( $conf, "RightsUrl", "<a href=\"" . htmlspecialchars( $conf->RightsUrl ) . "\">" . htmlspecialchars( $conf->RightsUrl ) . "</a>", "hidden" ); ?></li>
739 MediaWiki can include a basic license notice, icon, and machine-readable
740 copyright metadata if your wiki's content is to be licensed under
741 the GNU FDL
or a Creative Commons license
. If you
're not sure, leave
747 <?php aField( $conf, "SysopName", "Sysop account name:", "" ) ?>
750 <?php aField( $conf, "SysopPass", "password:", "password" ) ?>
753 <?php aField( $conf, "SysopPass2", "again:", "password" ) ?>
756 A sysop user account can lock or delete pages, block problematic IP
757 addresses from editing, and other maintenance tasks. If creating a new
758 wiki database, a sysop account will be created with the given name
763 <label class='column
'>Shared memory caching</label>
764 <div>Select one:</div>
767 <li><?php aField( $conf, "Shm", "no caching", "radio", "none" ); ?></li>
769 if ( $conf->turck ) {
771 aField( $conf, "Shm", "Turck MMCache", "radio", "turck" );
776 if ( $conf->eaccel ) {
778 aField( $conf, "Shm", "eAccelerator", "radio", "eaccel" );
782 <li><?php aField( $conf, "Shm", "Memcached", "radio", "memcached" ); ?></li>
783 <li><?php aField( $conf, "MCServers", "Memcached servers", "" ) ?></li>
787 Using a shared memory system such as Turck MMCache, eAccelerator, or Memcached will speed
788 up MediaWiki significantly. Memcached is the best solution but needs to be
789 installed. Specify the server addresses and ports in a comma-separted list. Only
790 use Turck shared memory if the wiki will be running on a single Apache server.
793 <h2>E-mail, e-mail notification and authentification setup</h2>
797 <label class='column
'>E-mail (general)</label>
798 <div>Select one:</div>
801 <li><?php aField( $conf, "Email", "enabled", "radio", "email_enabled" ); ?></li>
802 <li><?php aField( $conf, "Email", "disabled", "radio", "email_disabled" ); ?></li>
806 Use this to disable all e-mail functions (send a password reminder, user-to-user e-mail and e-mail notification),
807 if sending e-mails on your server doesn't work
.
810 <label
class='column'>User
-to
-user e
-mail
</label
>
811 <div
>Select one
:</div
>
814 <li
><?php
aField( $conf, "Emailuser", "enabled", "radio", "emailuser_enabled" ); ?
></li
>
815 <li
><?php
aField( $conf, "Emailuser", "disabled", "radio", "emailuser_disabled" ); ?
></li
>
819 Use this to disable only the user
-to
-user e
-mail
function (EmailUser
).
822 <label
class='column'>E
-mail notification
</label
>
823 <div
>Select one
:</div
>
826 <li
><?php
aField( $conf, "Enotif", "disabled", "radio", "enotif_disabled" ); ?
></li
>
827 <li
><?php
aField( $conf, "Enotif", "enabled for changes of watch-listed and user_talk pages (recommended for small wikis; perhaps not suited for large wikis)", "radio", "enotif_allpages" ); ?
></li
>
828 <li
><?php
aField( $conf, "Enotif", "enabled for changes of user_talk pages only (suited for small and large wikis)", "radio", "enotif_usertalk" ); ?
></li
>
833 $ccEnotif = htmlspecialchars( 'http://meta.wikipedia.org/Enotif' );
834 print "<a href=\"$ccEnotif\">E-mail notification</a>";
836 sends a notification e
-mail to a user
, when the user_talk page is changed
837 and/or when watch
-listed pages are changed
, depending on the above settings
.
838 When testing this feature
, be reminded
, that obviously an e
-mail address must be present in your preferences
839 and that your own changes never trigger notifications to be sent to yourself
.</p
>
841 <p
>Users get corresponding options to select
or deselect in their users
' preferences.
842 The user options are not shown on the preference page, if e-mail notification is disabled.</p>
844 <p>There are additional options for fine tuning in /includes/DefaultSettings.php .</p>
848 <label class='column
'>E-mail address authentication</label>
849 <div>Select one:</div>
852 <li><?php aField( $conf, "Eauthent", "disabled", "radio", "eauthent_disabled" ); ?></li>
853 <li><?php aField( $conf, "Eauthent", "enabled", "radio", "eauthent_enabled" ); ?></li>
858 $ccEauthent = htmlspecialchars( 'http
://meta.wikipedia.org/Eauthent' );
859 print "<a href=\"$ccEnotif\">E-mail address authentication</a>";
861 uses a scheme to authenticate e
-mail addresses of the users
. The user who initially enters
or who changes his
/her stored e
-mail address
862 gets a one
-time temporary password mailed to that address
. The user can
use the original password
as long
as wanted
, however
, the stored e
-mail address
863 is only authenticated at the moment when the user logs in with the one
-time temporary password
.<p
>
865 <p
>The e
-mail address stays authenticated
as long
as the user does not change it
; the time of authentication is indicated
866 on the user preference page
.</p
>
868 <p
>If the option is enabled
, only authenticated e
-mail addresses can receive EmailUser mails
and/or
869 e
-mail notification mails
.</p
>
874 <h2
>Database config
</h2
>
878 aField( $conf, "DBserver", "MySQL server" );
881 If your database server isn
't on your web server, enter the name
886 aField( $conf, "DBname", "Database name" );
889 aField( $conf, "DBuser", "DB username" );
892 aField( $conf, "DBpassword", "DB password", "password" );
895 aField( $conf, "DBpassword2", "again", "password" );
898 If you only have a single user account and database available,
899 enter those here. If you have database root access (see below)
900 you can specify new accounts/databases to be created.
904 aField( $conf, "DBprefix", "Database table prefix" );
907 <p>If you need to share one database between multiple wikis, or
908 MediaWiki and another web application, you may choose to
909 add a prefix to all the table names to avoid conflicts.</p>
911 <p>Avoid exotic characters; something like <tt>mw_</tt> is good.</p>
916 aField( $conf, "RootPW", "DB root password", "password" );
920 You will only need this if the database and/or user account
921 above don't already exist
.
922 Do <em
>not
</em
> type in your machine
's root password! MySQL
923 has its own "root" user with a separate password. (It might
924 even be blank, depending on your configuration.)
928 <label class='column
'> </label>
929 <input type="submit" value="Install!" />
939 /* -------------------------------------------------------------------------------------- */
941 function escapePhpString( $string ) {
942 return strtr( $string,
953 function writeLocalSettings( $conf ) {
954 $conf->DBmysql4 = @$conf->DBmysql4 ? 'true' : 'false';
955 $conf->UseImageResize = $conf->UseImageResize ? 'true' : 'false';
956 $conf->PasswordSender = $conf->EmergencyContact;
957 $zlib = ($conf->zlib ? "" : "# ");
958 $magic = ($conf->ImageMagick ? "" : "# ");
959 $convert = ($conf->ImageMagick ? $conf->ImageMagick : "/usr/bin/convert" );
960 $pretty = ($conf->prettyURLs ? "" : "# ");
961 $ugly = ($conf->prettyURLs ? "# " : "");
962 $rights = ($conf->RightsUrl) ? "" : "# ";
964 switch ( $conf->Shm ) {
966 $cacheType = 'CACHE_MEMCACHED
';
967 $mcservers = var_export( $conf->MCServerArray, true );
971 $cacheType = 'CACHE_ACCEL
';
972 $mcservers = 'array()';
975 $cacheType = 'CACHE_NONE
';
976 $mcservers = 'array()';
979 if ( $conf->Email == 'email_enabled
' ) {
980 $enableemail = 'true';
981 $enableuseremail = ( $conf->Emailuser == 'emailuser_enabled
' ) ? 'true' : 'false' ;
982 $eauthent = ( $conf->Eauthent == 'eauthent_enabled
' ) ? 'true' : 'false' ;
983 switch ( $conf->Enotif ) {
984 case 'enotif_usertalk
':
985 $enotifusertalk = 'true';
986 $enotifwatchlist = 'false';
988 case 'enotif_allpages
':
989 $enotifusertalk = 'true';
990 $enotifwatchlist = 'true';
993 $enotifusertalk = 'false';
994 $enotifwatchlist = 'false';
997 $enableuseremail = 'false';
998 $enableemail = 'false';
1000 $enotifusertalk = 'false';
1001 $enotifwatchlist = 'false';
1004 $file = @fopen( "/dev/urandom", "r" );
1006 $secretKey = bin2hex( fread( $file, 32 ) );
1010 for ( $i=0; $i<8; $i++ ) {
1011 $secretKey .= dechex(mt_rand(0, 0x7fffffff));
1013 print "<li>Warning: \$wgSecretKey key is insecure, generated with mt_rand(). Consider changing it manually.</li>\n";
1016 # Add slashes to strings for double quoting
1017 $slconf = array_map( "escapePhpString", get_object_vars( $conf ) );
1018 if( $conf->License == 'gfdl
' ) {
1019 # Needs literal string interpolation for the current style path
1020 $slconf['RightsIcon
'] = $conf->RightsIcon;
1023 $sep = (DIRECTORY_SEPARATOR == "\\") ? ";" : ":";
1025 # This file was automatically generated by the MediaWiki installer.
1026 # If you make manual changes, please keep track in case you need to
1027 # recreate them later.
1029 \$IP = \"{$slconf['IP
']}\";
1030 ini_set( \"include_path\", \".$sep\$IP$sep\$IP/includes$sep\$IP/languages\" );
1031 require_once( \"includes/DefaultSettings.php\" );
1033 # If PHP's memory limit is very low
, some operations may fail
.
1034 " . ($conf->raiseMemory ? '' : '# ' ) . "ini_set( 'memory_limit', '20M' );" . "
1036 if ( \
$wgCommandLineMode ) {
1037 if ( isset( \
$_SERVER ) && array_key_exists( 'REQUEST_METHOD', \
$_SERVER ) ) {
1038 die( \"This script must be run from the command line\\n\"
);
1040 } elseif ( empty( \
$wgConfiguring ) ) {
1041 ## Compress output if the browser supports it
1042 {$zlib}if( !ini_get( 'zlib.output_compression' ) ) @ob_start
( 'ob_gzhandler' );
1045 \
$wgSitename = \"{$slconf['Sitename']}\";
1047 \
$wgScriptPath = \"{$slconf['ScriptPath']}\";
1048 \
$wgScript = \"\
$wgScriptPath/index
.php\"
;
1049 \
$wgRedirectScript = \"\
$wgScriptPath/redirect
.php\"
;
1051 ## If using PHP as a CGI module, use the ugly URLs
1052 {$pretty}\
$wgArticlePath = \"\
$wgScript/\
$1\";
1053 {$ugly}\
$wgArticlePath = \"\
$wgScript?title
=\
$1\";
1055 \
$wgStylePath = \"\
$wgScriptPath/skins\"
;
1056 \
$wgStyleDirectory = \"\
$IP/skins\"
;
1057 \
$wgLogo = \"\
$wgStylePath/common
/images
/wiki
.png\"
;
1059 \
$wgUploadPath = \"\
$wgScriptPath/images\"
;
1060 \
$wgUploadDirectory = \"\
$IP/images\"
;
1062 \
$wgEnableEmail = $enableemail;
1063 \
$wgEnableUserEmail = $enableuseremail;
1065 \
$wgEmergencyContact = \"{$slconf['EmergencyContact']}\";
1066 \
$wgPasswordSender = \"{$slconf['PasswordSender']}\";
1068 ## For a detailed description of the following switches see
1069 ## http://meta.wikimedia.org/Enotif and http://meta.wikimedia.org/Eauthent
1070 ## There are many more options for fine tuning available see
1071 ## /includes/DefaultSettings.php
1072 ## UPO means: this is also a user preference option
1073 \
$wgEmailNotificationForUserTalkPages = $enotifusertalk; # UPO
1074 \
$wgEmailNotificationForWatchlistPages = $enotifwatchlist; # UPO
1075 \
$wgEmailAuthentication = $eauthent;
1077 \
$wgDBserver = \"{$slconf['DBserver']}\";
1078 \
$wgDBname = \"{$slconf['DBname']}\";
1079 \
$wgDBuser = \"{$slconf['DBuser']}\";
1080 \
$wgDBpassword = \"{$slconf['DBpassword']}\";
1081 \
$wgDBprefix = \"{$slconf['DBprefix']}\";
1083 # If you're on MySQL 3.x, this next line must be FALSE:
1084 \
$wgDBmysql4 = \
$wgEnablePersistentLC = {$conf->DBmysql4
};
1086 ## Shared memory settings
1087 \
$wgMainCacheType = $cacheType;
1088 \
$wgMemCachedServers = $mcservers;
1090 ## To enable image uploads, make sure the 'images' directory
1091 ## is writable, then uncomment this:
1092 # \$wgEnableUploads = true;
1093 \
$wgUseImageResize = {$conf->UseImageResize
};
1094 {$magic}\
$wgUseImageMagick = true;
1095 {$magic}\
$wgImageMagickConvertCommand = \"{$convert}\";
1097 ## If you have the appropriate support software installed
1098 ## you can enable inline LaTeX equations:
1099 # \$wgUseTeX = true;
1100 \
$wgMathPath = \"{\
$wgUploadPath}/math\"
;
1101 \
$wgMathDirectory = \"{\
$wgUploadDirectory}/math\"
;
1102 \
$wgTmpDirectory = \"{\
$wgUploadDirectory}/tmp\"
;
1104 \
$wgLocalInterwiki = \
$wgSitename;
1106 \
$wgLanguageCode = \"{$slconf['LanguageCode']}\";
1108 \
$wgProxyKey = \"$secretKey\";
1110 ## Default skin: you can change the default skin. Use the internal symbolic
1111 ## names, ie 'standard', 'nostalgia', 'cologneblue', 'monobook':
1112 # \$wgDefaultSkin = 'monobook';
1114 ## For attaching licensing metadata to pages, and displaying an
1115 ## appropriate copyright notice / icon. GNU Free Documentation
1116 ## License and Creative Commons licenses are supported so far.
1117 {$rights}\
$wgEnableCreativeCommonsRdf = true;
1118 \
$wgRightsPage = \"\"; # Set to the title of a wiki page that describes your license/copyright
1119 \
$wgRightsUrl = \"{$slconf['RightsUrl']}\";
1120 \
$wgRightsText = \"{$slconf['RightsText']}\";
1121 \
$wgRightsIcon = \"{$slconf['RightsIcon']}\";
1122 # \$wgRightsCode = \"{$slconf['RightsCode']}\"; # Not yet used
1126 function dieout( $text ) {
1127 die( $text . "\n\n
</body
>\n</html
>" );
1130 function importVar( &$var, $name, $default = "" ) {
1131 if( isset( $var[$name] ) ) {
1132 $retval = $var[$name];
1133 if ( get_magic_quotes_gpc() ) {
1134 $retval = stripslashes( $retval );
1142 function importPost( $name, $default = "" ) {
1143 return importVar( $_POST, $name, $default );
1146 function importRequest( $name, $default = "" ) {
1147 return importVar( $_REQUEST, $name, $default );
1150 function aField( &$conf, $field, $text, $type = "", $value = "" ) {
1152 $xtype = "type
=\"$type\"";
1157 if(!(isset($id)) or ($id == "") ) $id = $field;
1158 $nolabel = ($type == "radio
") || ($type == "hidden
");
1162 echo "\t\t
<label
class='column' for=\"$id\">$text</label
>\n";
1165 if( $type == "radio
" && $value == $conf->$field ) {
1166 $checked = "checked
='checked'";
1170 echo "\t\t
<input
$xtype name
=\"$field\" id
=\"$id\" $checked value
=\"";
1171 if( $type == "radio
" ) {
1172 echo htmlspecialchars( $value );
1174 echo htmlspecialchars( $conf->$field );
1178 echo " $text</label
>\n";
1182 if(isset($errs[$field])) echo "<span
class='error'>" . $errs[$field] . "</span
>\n";
1185 function getLanguageList() {
1186 global $wgLanguageNames;
1187 if( !isset( $wgLanguageNames ) ) {
1188 $wgContLanguageCode = "xxx
";
1189 function wfLocalUrl( $x ) { return $x; }
1190 function wfLocalUrlE( $x ) { return $x; }
1191 require_once( "languages
/Names
.php
" );
1196 $d = opendir( "../languages
" );
1197 while( false !== ($f = readdir( $d ) ) ) {
1198 if( preg_match( '/Language([A-Z][a-z_]+)\.php$/', $f, $m ) ) {
1199 $code = str_replace( '_', '-', strtolower( $m[1] ) );
1200 if( isset( $wgLanguageNames[$code] ) ) {
1201 $name = $code . ' - ' . $wgLanguageNames[$code];
1205 $codes[$code] = $name;
1213 # Test a memcached server
1214 function testMemcachedServer( $server ) {
1215 $hostport = explode(":", $server);
1218 if ( !function_exists( 'fsockopen' ) ) {
1219 $errstr = "Can
't connect to memcached, fsockopen() not present";
1221 if ( !$errstr && count( $hostport ) != 2 ) {
1222 $errstr = 'Please specify host
and port
';
1223 var_dump( $hostport );
1226 list( $host, $port ) = $hostport;
1230 $fp = @fsockopen( $host, $port, $errno, $fsockerr, 1.0 );
1231 if ( $fp === false ) {
1232 $errstr = "Cannot connect to memcached on $host:$port : $fsockerr";
1236 $command = "version\r\n";
1237 $bytes = fwrite( $fp, $command );
1238 if ( $bytes != strlen( $command ) ) {
1239 $errstr = "Cannot write to memcached socket on $host:$port";
1243 $expected = "VERSION ";
1244 $response = fread( $fp, strlen( $expected ) );
1245 if ( $response != $expected ) {
1246 $errstr = "Didn't get correct memcached response from
$host:$port";
1253 echo "<li
>Connected to memcached on
$host:$port successfully
";